import request from '@/utils/request'
import { requestWithNoTimeout } from '@/utils/request'

// 推送设置
export function selectCouponPushMessageRule() {
  return request({
    url:"/couponPushMessageRule/selectCouponPushMessageRule",
  })
}

// 推送设置修改
export function addOrUpdateCouponPushMessageRule(data) {
  return request({
    url:"/couponPushMessageRule/addOrUpdateCouponPushMessageRule",
    method: "post",
    data
  })
}

// 查询客户管理列表  用
export function listManage(query) {
  return request({
    url: '/appUserInfo/info/list',
    method: 'get',
    params: query
  })
}

// 查询会员数量
export function numberMembers(query) {
  return request({
    url: '/appUserInfo/info/getAppUserNumber',
    method: 'get',
    params: query
  })
}

export function listSum(query) {
  return request({
    //url: '/member/message/selectMemberSum',
    url: '/appUserInfo/info/selectAppUserInfoSum',
    method: 'get',
    params: query
  })
}



// 查询客户管理详细
export function getManage(id) {
  return request({
    url: '/customer/manage/' + id,
    method: 'get'
  })
}

// 新增客户管理
export function addManage(data) {
  return request({
    url: '/customer/manage',
    method: 'post',
    data: data
  })
}

// 修改客户管理
export function updateManage(data) {
  return request({
    url: '/customer/manage',
    method: 'put',
    data: data
  })
}

// 删除客户管理
export function delManage(id) {
  return request({
    url: '/customer/manage/' + id,
    method: 'delete'
  })
}

// 导出客户管理
export function exportManage(query) {
  return request({
    url: '/customer/manage/export',
    method: 'get',
    params: query
  })
}
// 导出客户管理
export function exportList(query) {
  return request({
    url: '/appUserInfo/info/exportList',
    method: 'get',
    params: query
  })
}
export function getOrderInfo(query) {
  return request({
    url: '/station/order/list',
    method: 'get',
    params: query
  })
}

//会员卡发送模板消息
export function sendMessageToUser(query) {
  return requestWithNoTimeout({
    url: '/appUserInfo/info/sendMessageToUser',
    method: 'post',
    data: query
  })
}
// 批量推送
export function sendMessageToUserBatch(data) {
  return request({
    url: "/appUserInfo/info/sendMessageToUserBatch",
    method: "post",
    data,
  })
}

//优惠券发送模板消息
export function activeSendMessage(query) {
  return request({
    url: '/appUserInfo/info/activeSendMessage',
    method: 'post',
    data: query
  })
}

//选择分类发送模板消息
export function selectSendMessage(query) {
  return requestWithNoTimeout({
    url: '/appUserInfo/info/selectSendMessage',
    method: 'post',
    data: query
  })
}

export function getUseRecord(query) {
  return request({
    url: '/appUserInfo/info/listUseRecordByAppUserInfo',
    method: 'get',
    params: query
  })
}

export function sendToYunHua(data) {
  return request({
    url: '/appUserInfo/info/sendUserToYunHua',
    method: 'post',
    data: data
  })
}

// 下载模版
export function importTemplate(query) {
  return request({
    url: '/appUserInfo/info/importTemplate',
    method: 'get',
    params: query
  })
}

// 查询会员电子卡列表
export function cardUserList(query) {
  return request({
    url: '/customer/card/user/list',
    method: 'get',
    params: query
  })
}

// 更新会员电子卡余额
export function updateUserRecord(data) {
  return request({
    url: '/customer/card/user/updateUserRecord',
    method: 'post',
    data: data
  })
}

// 更新会员电子卡余额（新） 包含消息推送，操作类型等
export function electronicCardUpdateUserRecordApi(data){
  return request({
    url:"/electronicCardUpdateUserRecord/updateUserRecord",
    method:"post",
    data:data
  })
}


// 刷新会员列表数据
export function updateUserMemberCodeApi(enterpriseId){
  return request({
    url:"/appUserInfo/info/updateUserMemberCode",
    method:"post",
    params:enterpriseId
  })
}

// 重置会员密码
export function restPasswordApi(userId){
  return request({
    url:`/appUserInfo/info/restPassword?userId=${userId}`,
    method:"get"
  })
}
// 修改车牌号
export function updateCarNo(data) {
  return request({
    url: '/appUserInfo/info/increaseTruckNumber',
    method: 'post',
    data
  })
}

// 更新openId
export function updateOpenId(userId) {
  return request({
    url:`appUserInfo/info/updateOpenId/${userId}`,
  })
}
